const db=wx.cloud.database();

//获取全部可捐助的物品
export const getAllGoods= async(_openid,page) => {
  var res =await db.collection("good").get();
  //console.log(res.data);
  return res;
}

//获取全部可捐助的项目
export const getAllProjects=async(_openid,page) =>{
  var res =await db.collection("project").get();
  //console.log(res);
  return res;
}

//通过关键词来搜索
export const serachByKeyword=async(keyword) =>{
  console.log('搜索关键词：',keyword);
  try {
    if(keyword===''){
      var res = await db.collection('good').get();
    }else{
      var res = await db.collection('good')
      .where({ category: keyword }).get();
      console.log(res.data);
    }
  
    return res.data
  } catch (err) {
    console.error(err);
  }


}